#define _CRT_SECURE_NO_WARNINGS 1

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
bool hasCycle(struct ListNode* head)
{
    struct ListNode* show = head;
    struct ListNode* fast = head;
    while (fast && fast->next)
    {
        show = show->next;
        fast = fast->next->next;
        if (fast == show)
        {
            return true;
        }
    }
    return false;
}